<?php

require_once "../../app/dao/message_dao.php";
require_once "../../config/paging.php";

include_once "header.php";

$modul=$_GET['modul'];
$id=$_GET['id'];
$breadcrump ="";

echo "<div class='container'>
<div class='row'>";

switch($modul){
    
    default :
	
		$p = new Paging;
        $batas = 10;
        $posisi = $p->cari_posisi($batas);
		
        echo "
            
            <table class='table table-bordered'>
                <tr><td colspan=6><a href='user_view.php?modul=tambah'><image src='../images/add.png'></a></td></tr>
                <th>ID</th><th>NAMA PENGIRIM</th><th>EMAIL</th><th>JUDUL</th><th>ISI PESAN</th><th>AKSI</th>
                ";
				
        $message = new Message_Dao($class_db);
        
        $message->get_message(null,$posisi,$batas);
        
        //$jmldata = count($message->message);
        
        $data = $message->message;
        
        if($data!=null) {
            
           foreach($data as $message) {            
            
			echo "
                <tr valign = top>
                    <td>$message->message_id</td>
                    <td>$message->sender</td>                   
                    <td>$message->email</td>
					<td>$message->subject</td>
					<td>$message->content</td>
                    <td><a href='user_view.php?modul=ubah&id=$message->message_id'><image src='../images/edit.gif'></a> | 
                        <a href='user_aksi.php?modul=hapus&id=$message->message_id'><image src='../images/delete.gif'></a></td>
                </tr>
                ";        
            
            } 
        }else{
            echo "<tr><td colspan=5 align=center>DATA TIDAK DITEMUKAN</td></tr>";
        }
        
        echo "            
            </table>
            ";
    break;    
	
	echo "</div></div>";  
}
?>